package top.yuhaitao.core.service.impl;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import top.yuhaitao.core.enums.ProductInfostatus;
import top.yuhaitao.core.pojo.ProductInfo;
import top.yuhaitao.core.repository.ProductInfoRepository;
import top.yuhaitao.core.service.ProductInfoService;

@Service
public class ProductInfoServiceImpl implements ProductInfoService {

	@Autowired
	private ProductInfoRepository productInfoRepository;

	@Override
	public ProductInfo findOne(String productId) {
		Optional<ProductInfo> findById = productInfoRepository.findById(productId);
		return findById.orElse(new ProductInfo());
	}

	@Override
	public List<ProductInfo> findUpAll() {

		return productInfoRepository.findByProductStatus(ProductInfostatus.UP.getStatus());

	}

	@Override
	public List<ProductInfo> findAll(Pageable pageable) {
		// TODO Auto-generated method stub
		Page<ProductInfo> findAll = productInfoRepository.findAll(pageable);
		return findAll.getContent();
	}

	@Override
	public ProductInfo save(ProductInfo ProductInfo) {
		// TODO Auto-generated method stub
		return null;
	}

}
